home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Games / JST / sources / src / loaders / DesertStrike / dshd.asm < prev    next >
Encoding:
Assembly Source File  |  2001-03-19  |  6.8 KB  |  411 lines

  1. ; *** Desert Strike Hard Disk Loader
  2. ; *** Written by Jean-François Fabre (jffabre@club-internet.fr)
  3.  
  4. ;                                           fastsize   fastbuff
  5. ;                                               |          |
  6. ; on A500: $200: E  T  C  !  00 00 02 08 00 17 E3 18 00 C0 04 E8
  7. ; 2MB      $210: 00 05 00 07 FB E0 00 00 04 20 00 03 00 00 00 00    
  8. ;                            |            |
  9. ;                          topchip     lowchip
  10.  
  11. ; on A500: $200: E  T  C  !  00 00 02 08 00 07 E3 18 00 C0 04 E8
  12. ; 1MB      $210: 00 05 00 07 FB E0 00 00 04 20 00 03 00 00 00 00    
  13.  
  14. ; on 1200: $200: E  T  C  !  00 00 02 08 00 F7 FF E0 68 00 02 00
  15. ; 68060    $210: 00 05 00 1F EF E0 00 00 10 20 07 03 00 00 00 00    
  16.  
  17.  
  18.     include    "jst.i"
  19.  
  20.     HD_PARAMS    "DStrike.d",STD_DISK_SIZE,3    ; JST parameters
  21.     SET_VARZONE    startvar,endvar            ; local variables
  22.  
  23. loader:
  24.     move.l    #$80000,D0
  25.     JSRABS    Alloc24BitMem
  26.     RELOC_MOVEL    D0,ExtBase
  27.     beq    MemErr
  28.  
  29.     Mac_printf    "Desert Strike HD Loader V2.1"
  30.     Mac_printf    "Coded by Jean-Francois Fabre © 1996/1998"
  31.  
  32.     JSRABS    LoadDisks
  33.  
  34.     moveq.l    #0,D0
  35.     move.l    #CACRF_CopyBack,D1
  36.     JSRABS    Degrade        ; Also flushes the caches
  37.  
  38. ;    WAIT_LMB
  39.  
  40.     GO_SUPERVISOR
  41.     SAVE_OSDATA    $80000
  42.     
  43.     MOVE    #$2700,SR        ;0DA: 46FC2700
  44.  
  45.     bsr    InstallBoot
  46.  
  47.     bsr    MemoryConfig
  48.  
  49.     JSRGEN    FlushCachesHard
  50.     JMP    $5800E
  51.  
  52.     nop
  53.     nop
  54.     nop
  55.     nop
  56.  
  57. JsrIntro2:
  58. ;    move.l    ExtBase(pc),$210E.W
  59.  
  60.     move.l    $210E.W,A0
  61.     add.l    #$1C566,A0
  62.     cmp.l    #$48E77FFC,(A0)
  63.     bne    exit$
  64.  
  65.     ; *** rob loader
  66.  
  67.     PATCHUSRJMP    (A0),ReadSectors
  68.  
  69.     ; *** store extbase
  70.  
  71.     RELOC_MOVEL    $210E.W,ExtBase
  72.  
  73.     ; *** intercept copper pointer pokes
  74.  
  75.     STORE_REGS
  76.     move.l    $210E.W,A0
  77.     lea    ($67C0,A0),A0
  78.     move.l    $210E.W,A1
  79.     add.l    #$1D000,A1
  80.     move.l    #$F,D1
  81.     JSRGEN    PatchMoveCList_Ind
  82.     RESTORE_REGS
  83.  
  84.     ; *** remove trap handler
  85.  
  86.     move.l    $210E.W,A0        ; ExtBase, actually
  87.     add.l    #$1B2A4,A0
  88.     move.w    #$4E75,(A0)
  89.  
  90.     ; *** 2nd button check
  91.  
  92.     move.l    $210E.W,A0
  93.     add.l    #$99A2,A0
  94.     move.w    #$4E71,(A0)+
  95.     PATCHUSRJSR    (A0),Check2ndButton
  96.  
  97.     ; *** 2nd button detect in VBLANK interrupt
  98.  
  99.     move.l    $210E.W,A0
  100.     add.l    #$A9C,A0
  101.     move.w    #$4E71,(A0)+
  102.     PATCHUSRJSR    (A0),Read2ndButton
  103.  
  104.     ; *** keyboard interrupt
  105.  
  106.     move.l    $210E.W,A0
  107.     PATCHUSRJSR    (A0,$976),KbInt_1
  108.  
  109.  
  110.     ; *** decrunch in fastmem
  111.  
  112.     move.l    $210E.W,A0
  113.     add.l    #$1CAD2,A0
  114.     PATCHGENJMP    (A0),RNCDecrunch
  115.  
  116.     ; *** patch another loader
  117.  
  118.     move.l    $210E.W,A0
  119.     add.l    #$1BC38,A0    
  120.     PATCHUSRJSR    (A0),JsrLoader3
  121.  
  122.     ; *** patch set disk
  123.  
  124.     move.l    $210E.W,A0
  125.     add.l    #$1C2CA,A0
  126.     PATCHUSRJMP    (A0),SetDisk
  127.  
  128.     ; *** drive light
  129.  
  130.     move.l    $210E.W,A0
  131.     add.l    #$1C10C,A0
  132.     move.w    #$4E75,(A0)
  133.  
  134. exit$
  135.  
  136.     ; *** flush and run
  137.  
  138.     JSRGEN    FlushCachesHard
  139.     move.l    $210E.W,A0
  140.     nop
  141.     nop
  142.     rts
  143.     nop
  144.     nop
  145.  
  146. JsrLoader3:
  147.  
  148.     ; contenu de $1BCEA+ExtBase
  149.  
  150.     cmp.l    #$48E77FFC,$3AF4.W
  151.     bne    patch2$
  152.  
  153.     ; *** rob read
  154.  
  155.     PATCHUSRJMP    $3AF4.W,ReadSectors    ; rob read
  156.  
  157.     ; *** decrunch
  158.  
  159.     PATCHGENJMP    $4060.W,RNCDecrunch    ; decrunch
  160.  
  161.     ; *** no LED
  162.  
  163.     move.l    #$4E714E71,$33C0.W        ; led off
  164.     move.w    #$4E75,$369A.W            ; led off
  165.     bra    go$
  166.  
  167. patch2$
  168.     cmp.l    #$13C00000,$F92.W
  169.     bne    patch3$
  170.     PATCHUSRJSR    $F92.W,KbInt_2        ; keyboard menu
  171.     bra    go$
  172.  
  173. patch3$
  174.     cmp.l    #$48E7FFFE,$1A170
  175.     bne    patch4$
  176.  
  177.     PATCHUSRJMP    $1A170,SetDisk        ; set proper disk
  178.     PATCHUSRJMP    $1A40C,ReadSectors    ; rob read
  179.     move.w    #$4E75,$19FB2            ; led off
  180.     bra    go$
  181.  
  182. patch4$
  183. go$
  184.     JSRGEN    FlushCachesHard
  185.  
  186.     ; bugfix (A0 was fixed at $200)
  187.  
  188.     move.l    ExtBase(pc),A0
  189.     add.l    #$1BCEA,A0
  190.     move.l    (A0),A0
  191.  
  192.     rts
  193.  
  194.  
  195. Read2ndButton:
  196.     move.l    D0,-(A7)
  197.     RELOC_CLRL    Fire2Pressed
  198.  
  199.     move.w    $DFF016,D0
  200.     btst    #14,D0
  201.     bne    exit$
  202.     RELOC_STL    Fire2Pressed
  203.     move.w    #$CC01,$DFF034
  204. exit$
  205.     move.l    (a7)+,D0
  206.     move.w    #$70,$DFF000+intreq
  207.     rts
  208.  
  209. Check2ndButton:
  210.     movem.l    D0/A0,-(sp)
  211.  
  212.     move.l    ExtBase(pc),A0
  213.     add.l    #$186D6,A0
  214.  
  215.     RELOC_TSTL    Fire2Pressed
  216.     beq    nob2$
  217.  
  218.     bset.b    #7,(A0)        ; simulate space pressed
  219. nob2$
  220.     btst.b    #7,(A0)        ; original code
  221.     movem.l    (sp)+,D0/A0
  222.     rts
  223.  
  224. JsrIntro:
  225.     JSRGEN    FlushCachesHard
  226.     move.l    IntroAddr(pc),-(A7)
  227.     rts
  228.  
  229. KbInt_2:
  230.     move.b    D0,($FD6).W
  231.     cmp.b    #$54,D0
  232.     bne    noquit$
  233.     JSRGEN    InGameExit
  234. noquit$
  235.     rts
  236.  
  237. KbInt_1:
  238.     lea    $BFE001,A0
  239.     move.l    D0,-(a7)
  240.     move.b    (A0,$C00),D0
  241.     ror.b    #1,D0
  242.     not.b    D0
  243.     cmp.b    #$54,D0
  244.     bne    noquit$
  245.     JSRGEN    InGameExit
  246. noquit$
  247.     cmp.b    #$42,D0
  248.     bne    noicon$
  249.     JSRGEN    InGameIconify
  250.     STORE_REGS
  251.     move.l    ExtBase(pc),A0
  252.     JSR    $74E6(A0)        ; restart chopper noise
  253.     RESTORE_REGS
  254. noicon$
  255.     move.l    (a7)+,D0
  256.     rts
  257.  
  258. Patch800:
  259.     lea    $2714.W,A7
  260.     move    #$2700,SR
  261.     move.w    #$1FF,dmacon+$DFF000
  262.  
  263.     RELOC_MOVEL    $86A.W,IntroAddr
  264.     PATCHUSRJMP    $12D4.W,ReadSectors
  265.     PATCHUSRJMP    $1840.W,Decrunch
  266.     PATCHUSRJSR    $868.W,JsrIntro
  267.     PATCHUSRJSR    $205C.W,JsrIntro2
  268.     JSRGEN    GoECS
  269.     JSRGEN    FlushCachesHard
  270.     nop
  271.     nop
  272.     jmp    $840.W
  273.  
  274.  
  275. MemoryConfig:
  276.     lea    $200.W,A1
  277.     move.l    #'ETC!',(A1)+        ; $200
  278.     move.l    #$208,(A1)+        ; $204
  279.     move.l    #$80000,(A1)+        ; $208 fastsize
  280.     move.l    ExtBase(pc),(a1)+    ; $20C fastbuf
  281.     move.w    #$5,(A1)+        ; $20E
  282.     move.l    #$0007FBE0,(A1)+    ; $210 topchip (512K)
  283.     move.l    #$420,(A1)+        ; $214 lowchip
  284.     move.w    #$300,(A1)+        ; $218 ??
  285.     clr.l    (A1)+            ; $21C
  286.     rts
  287.  
  288. InstallBoot:
  289.     JSRGEN    InitTrackDisk
  290.     MOVEQ    #0,D7        
  291.     move.l    #$10400,D0
  292.     MOVE.L    D0,D3        
  293.     MOVE.L    D0,40(A1)    
  294.     MOVE.L    #$00000200,36(A1)
  295.     MOVE.L    #$00000400,44(A1)
  296.     MOVE    #$0002,28(A1)
  297.     JSRGEN    TrackLoad
  298.  
  299.     MOVEA.L    D3,A0            ;062: 2043
  300.     MOVE.L    4(A0,D7.W),D0        ;064: 20307004
  301.     ADDI.L    #$000003FF,D0        ;068: 0680000003FF
  302.     ANDI.L    #$FFFFFE00,D0        ;06E: 0280FFFFFE00
  303.     MOVE.L    D0,D5            ;074: 2A00
  304.     SUBI.L    #$00000200,D5        ;076: 048500000200
  305.  
  306.     MOVEA.L    D3,A0            ;090: 2043
  307.     MOVE.L    #$00058000,40(A1)    ;094: 237C000580000028
  308.     MOVE.L    D5,36(A1)        ;09C: 23450024
  309.     MOVE.L    0(A0,D7.W),44(A1)    ;0A0: 23707000002C
  310.     MOVE    #$0002,28(A1)        ;0A6: 337C0002001C
  311.     JSRGEN    TrackLoad
  312.  
  313.     MOVEA.L    D3,A1            ;0E6: 2243
  314.     CLR.L    (A1)+            ;106: 4299
  315.  
  316.     MOVEA.L    D3,A2            ;126: 2443
  317.     LEA    $200.W,A6        ;128: 4DF900000200
  318.     MOVE.L    #$45544321,0(A6)    ;12E: 2D7C455443210000
  319.     LEA    8(A6),A4        ;136: 49EE0008
  320.     MOVE.L    A4,4(A6)        ;13A: 2D4C0004
  321. LAB_0005:
  322.     MOVE.L    (A2)+,(A4)+        ;13E: 28DA
  323.     BEQ.S    LAB_0006        ;140: 6706
  324.     MOVE.L    (A2)+,(A4)+        ;142: 28DA
  325.     MOVE    (A2)+,(A4)+        ;144: 38DA
  326.     BRA.S    LAB_0005        ;146: 60F6
  327. LAB_0006:
  328.  
  329.     lea    $58000,A0
  330.     PATCHUSRJMP    ($BFE,A0),ReadSectors
  331.     PATCHUSRJMP    ($1A2,A0),Patch800
  332.     PATCHGENJMP    ($116A,A0),RNCDecrunch
  333.     move.w    #$4E75,($962,A0)        ; remove insert disk 1
  334.  
  335.     rts
  336.  
  337. ; ReadSectors (Rob Northen)
  338.  
  339. ReadSectors:
  340.     STORE_REGS
  341.     move.w    currdisk(PC),D0
  342.     and.w    #3,D0
  343.  
  344.     JSRGEN    ReadRobSectors
  345.     
  346.     RESTORE_REGS
  347.     rts
  348.  
  349.  
  350. Decrunch:
  351.     JSRGEN    RNCDecrunch
  352.     JSRGEN    FlushCachesHard
  353.     rts
  354.  
  355. PatchBoot:
  356.     STORE_REGS
  357.     moveq.l    #0,D0
  358.     JSRGEN    GetDiskPointer        ; 1st disk
  359.     move.l    D0,A0
  360.  
  361.     ; *** Patch so it's compatible with another version
  362.  
  363.     move.l    A0,A2
  364.     add.l    #$6E014,A2
  365.     move.l    #$9223455a,(A2)
  366.  
  367.     move.l    A0,A2
  368.     add.l    #$6E1A4,A2
  369.  
  370.     move.l    #$1608,(A2)+
  371.     move.l    #$4a9,(A2)+
  372.     move.l    #$5d,(A2)+
  373.  
  374.     move.l    A0,A2
  375.     add.l    #$6E1C4,A2
  376.  
  377.     move.l    #$31652044,(A2)+
  378.     move.l    #$69736b20,(A2)+
  379.     move.l    #$31000000,(A2)+
  380.  
  381.     move.l    A0,A2
  382.     add.l    #$6E1E4,A2
  383.  
  384.     move.l    #$1608,(A2)+
  385.     move.l    #$4a9,(A2)+
  386.     move.l    #$5d,(A2)+
  387.  
  388.     RESTORE_REGS
  389.     rts
  390.  
  391. SetDisk:
  392.     and.w    #15,D0
  393.     RELOC_MOVEW    D0,currdisk
  394.     rts
  395.  
  396. MemErr:
  397.     Mac_printf    "** Not enough memory!!"
  398.     JMPABS    CloseAll
  399.  
  400. startvar:
  401.  
  402. ExtBase:
  403.     dc.l    0
  404. IntroAddr:
  405.     dc.l    0
  406. Fire2Pressed:
  407.     dc.l    0
  408. currdisk:
  409.     dc.w    0
  410. endvar:
  411.